package com.arraylistdemo;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class PokerTest {
    public static void main(String[] args) {
        List<Poker> pokers = new ArrayList<>();
        String[] flow = {"♦️","♥️","♠️","♣️"};
        String[] num = {"3","4","5","6","7","8","9","10","J","Q","K","A","2"};
           int k = 0;
        for (int i = 0; i < num.length; i++) {
            for (int j = 0; j < flow.length; j++) {
                pokers.add(new Poker(flow[j] + num[i],k));
                k++;
            }
        }
        pokers.add(new Poker("小王",52));
        pokers.add(new Poker("大王",53));
        Collections.shuffle(pokers);


        List<Poker> play1  = new ArrayList<>();
        List<Poker> play2  = new ArrayList<>();
        List<Poker> play3  = new ArrayList<>();
        List<Poker> dipai  = new ArrayList<>();

        for (int i = 0; i < pokers.size(); i++) {
            if (i >= 51) {
                dipai.add(pokers.get(i));
            }else if (i % 3 == 0) {
                play1.add(pokers.get(i));
            }else if (i % 3 == 1) {
                play2.add(pokers.get(i));
            }else if (i % 3 == 2) {
                play3.add(pokers.get(i));
            }
        }
        for (int i = 0; i < 3; i++) {
            Collections.sort(play1, new Comparator<Poker>() {
                @Override
                public int compare(Poker o1, Poker o2) {
                    return o1.getLevel() - o2.getLevel();
                }
            });
        }
        System.out.println(sort(play1));
        System.out.println(sort(play2));
        System.out.println(sort(play3));


    }
    public static List<Poker> sort(List<Poker> list) {
        Collections.sort(list, new Comparator<Poker>() {
            @Override
            public int compare(Poker o1, Poker o2) {
                return o1.getLevel() - o2.getLevel();
            }
        });
        return list;
    }
}
